package com.chinasoft.goodsManager.servlet;

import com.alibaba.fastjson.JSON;
import com.chinasoft.goodsManager.daomaingoodslist.UserList;
import com.chinasoft.goodsManager.goodslistserver.impl.ListServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/useradd")
public class UserAddServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        String pname = request.getParameter("pname");
        String idcard = request.getParameter("idcard");
        String job = request.getParameter("job");
        String psalary= request.getParameter("psalary");
        String wyear = request.getParameter("wyear");
        String mphone = request.getParameter("mphone");
        String qq = request.getParameter("qq");
        String pemail = request.getParameter("pemail");
        String paddress = request.getParameter("paddress");
        String pdescrike = request.getParameter("pdescrike");
        UserList userList = new UserList();
        userList.setPname(pname);
        userList.setIdcard(idcard);
        userList.setJob(job);
        userList.setPsalary(psalary);
        userList.setWyear(Integer.valueOf(wyear));
        userList.setMphone(mphone);
        userList.setQq(qq);
        userList.setPemail(pemail);
        userList.setPaddress(paddress);
        userList.setPdescrike(pdescrike);
        ListServiceImpl service = new ListServiceImpl();
        //创建用户
        service.add(userList);


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
